<template>
  <div>
    <header>
      <div class="logo">
        <img src="@/assets/logo.png" alt="">
      </div>
      <div class="search">
        <img src="@/assets/search.png" alt="">
        <input type="text" placeholder="黑五嗨购节">
      </div>
      <div class="msg">
        <img src="@/assets/msg.png" alt="">
      </div>
    </header>
    <div class="whitespace"/>
    <div class="banner">
      <mt-swipe :auto="4000">
        <mt-swipe-item
        v-for="item of banner"
        class="slide1"
        :key="item.id"
        >
          <img :src="item.img" alt="">
        </mt-swipe-item>
      </mt-swipe>
    </div>
    <div class="hotLinks">
      <ul>
        <li
        v-for="item of hots"
        :key="item.id">
          <img :src="item.img" alt="">
          <span>{{ item.title }}</span>
        </li>
      </ul>
    </div>
    <div class="space" />
    <div class="list">
      <router-link
      tag="div"
      :to="{
        name: 'details',
        params: {
          id: prod.id,
          prod,
        }
      }"
      class="item"
      v-for="prod of list"
      :key="prod.id">
        <div class="thumb">
          <img :src="prod.prodImg[0].image" alt="">
          <div class="notice">
            <div>
              <span>新品</span>
            </div>
          </div>
        </div>
        <div class="info">
          <span class="desc">{{ prod.name }}</span>
          <div class="price">
            <i>￥</i>
            <span>{{ prod.price }}</span>
          </div>
        </div>
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Home',
  data () {
    return {
      banner: [],
      hots: [],
      list: []
    }
  },
  methods: {
  },
  mounted () {
    this.$http('/api/banner').then(resp => {
      this.banner = resp.data.res_body.data
    })
    this.$http('/api/hot').then(resp => {
      this.hots = resp.data.res_body.data
    })
    this.$http('/api/Mall').then(resp => {
      this.list = resp.data.res_body.mallList[0].data[0].prodList
    })
  }
}
</script>

<style lang="scss" scoped>
  header {
    width: 100%;
    height: 38px;
    background-color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    z-index: 9999;
    .logo {
      img {
        height: 28px;
        padding: 0 6px;
      }
    }
    .search {
      height: 28px;
      flex: 1;
      background-color: #eee;
      border-radius: 1.5px;
      display: flex;
      align-items: center;
      img {
        width: 13px;
        height: 13px;
        margin-left: 6px;
      }
      input {
        flex: 1;
        height: 16px;
        border: none;
        background-color: #eee;
        padding-left: 6px;
        font-size: 12px;
        color: #999;
      }
      input:focus {outline: none;}
    }
    .msg {
      img {
        height: 28px;
        padding: 0 6px;
      }
    }
  }
  .whitespace {
    width: 100%;
    height: 38px;
    background-color: #fff;
  }
  .banner {
    height: 176px;
    img {
      width: 100%;
      height: 176px;
    }
  }
  .hotLinks {
    height: 85px;
    width: 100%;
    ul {
      padding-top: 9px;
      display: flex;
      justify-content: space-around;
      li {
        width: 48px;
        height: 74px;
        img {
          display: block;
          width: 45px;
          height: 45px;
        }
        span {
          display: block;
          font-size: 12px;
          margin-top: 8px;
          text-align: center;
          color: rgb(85, 86, 102);
          line-height: 14px;
        }
      }
    }
  }
  .space {
    width: 100%;
    height: 10px;
    background-color: #f4f4f4;
  }
  .list {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    .item {
      width: 113px;
      height: 189px;
      .thumb {
        width: 113px;
        height: 121px;
        position: relative;
        overflow: hidden;
        background-color: rgb(248, 248, 248);
        img {
          display: block;
          width: 86px;
          height: 86px;
          margin: auto;
          margin-top: 13px;
        }
        .notice {
          position: absolute;
          width: 113px;
          height: 15px;
          bottom: 0;
          left: 0;
          span {
            white-space: nowrap;
            display: inline-block;
            font-size: 10px;
            line-height: 16px;
            text-align: center;
            color: rgb(255, 255, 255);
            padding: 0 4px;
            overflow: hidden;
            background-color: green;
            border-radius: 2px;
          }
        }
      }
      .info {
        width: 110px;
        height: 60px;
        margin-top: 12px;
        margin-right: 2px;
        padding-left: 11px;
        .desc {
          white-space: pre-wrap;
          position: relative;
          box-sizing: border-box;
          display: box;
          flex-direction: column;
          align-content: flex-start;
          flex-shrink: 0;
          font-size: 14px;
          line-height: 16px;
          width: 109px;
          color: rgb(51, 51, 51);
          text-align: left;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .price {
          box-sizing: border-box;
          display: flex;
          flex-direction: row;
          place-content: flex-start;
          flex-shrink: 0;
          height: 15px;
          width: 109px;
          margin-top: 10px;
          -webkit-box-align: end;
          align-items: flex-end;
          i {
            display: block;
            font-size: 10px;
            line-height: 13px;
            height: 13px;
            color: rgb(182, 9, 9);
            text-align: left;
            margin-right: 2px;
            margin-bottom: 1px;
            overflow: hidden;
          }
          span {
            display: block;
            font-size: 15px;
            line-height: 17px;
            height: 17px;
            color: rgb(182, 9, 9);
            text-align: left;
            overflow: hidden;
          }
        }
      }
    }
  }
</style>
